home *** CD-ROM | disk | FTP | other *** search
/ Pesquisa Dirigida / Pesquisa Dirigida.iso / JOGOS / parking.swf / scripts / soundcontrol.as < prev    next >
Text File  |  2005-01-18  |  1KB  |  49 lines

  1. function SoundControl()
  2. {
  3.    this.swapDepths(10);
  4.    this.silent_mc._visible = false;
  5.    _root.control_sound = new Sound(_root);
  6.    this.muted = false;
  7.    this.fadein = false;
  8.    this.onRelease = this.clicked;
  9. }
  10. SoundControl.prototype = new MovieClip();
  11. SoundControl.prototype.clicked = function()
  12. {
  13.    if(this.muted)
  14.    {
  15.       this.unmuteAllSounds();
  16.    }
  17.    else
  18.    {
  19.       this.muteAllSounds();
  20.    }
  21. };
  22. SoundControl.prototype.muteAllSounds = function()
  23. {
  24.    if(this.fadein)
  25.    {
  26.       delete this.onEnterFrame;
  27.       this.fadein = false;
  28.    }
  29.    _root.control_sound.setVolume(0);
  30.    this.silent_mc._visible = true;
  31.    this.muted = true;
  32. };
  33. SoundControl.prototype.unmuteAllSounds = function()
  34. {
  35.    this.fadein = true;
  36.    this.silent_mc._visible = false;
  37.    this.muted = false;
  38.    this.onEnterFrame = function()
  39.    {
  40.       _root.control_sound.setVolume(_root.control_sound.getVolume() + 10);
  41.       if(_root.control_sound.getVolume() >= 100)
  42.       {
  43.          this.fadein = false;
  44.          delete this.onEnterFrame;
  45.       }
  46.    };
  47. };
  48. Object.registerClass("soundcontrol",SoundControl);
  49.